//
//  SY_Par_PaymentCell.m
//  ChatDemo-UI2.0
//
//  Created by Sylar on 2016/12/29.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "SY_Par_PaymentCell.h"

@implementation SY_Par_PaymentCell {
    
    UILabel *titleLabel;
    UILabel *dateLabel;
    UILabel *contentLabel;
    UILabel *stateLabel;
    
    UIImageView *leftImg;
    UIImageView *rightImg;
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        leftImg = [[UIImageView alloc]initWithFrame:CGRectMake(15, 8, 64, 64)];
        [self.contentView addSubview:leftImg];
        
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(leftImg.right + 19, 20, SCREENWIDTH - 146, 16)];
        [titleLabel setFont:[UIFont systemFontOfSize:16]];
        [titleLabel setTextColor:colorFromHex(@"#000000")];
        [self.contentView addSubview:titleLabel];
        
//        dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 15, 150, 17)];
//        [dateLabel setFont:[UIFont systemFontOfSize:17]];
//        [dateLabel setTextColor:colorFromHex(@"")];
//        [self.contentView addSubview:dateLabel];
        
        contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(titleLabel.x, titleLabel.bottom+9, SCREENWIDTH - 146, 15)];
        [contentLabel setFont:[UIFont systemFontOfSize:15]];
        [contentLabel setTextColor:colorFromHex(@"#979797")];
        [self.contentView addSubview:contentLabel];
        
        stateLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREENWIDTH - 60, 58, 45, 14)];
        [stateLabel setFont:[UIFont systemFontOfSize:14]];
        [stateLabel setTextColor:colorFromHex(@"#fea356")];
        stateLabel.text = @"进行中";
        stateLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:stateLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 79.5, SCREENWIDTH, 0.5)];
        [lineView setBackgroundColor:colorFromHex(@"#DEDEDE")];
        [self.contentView addSubview:lineView];
        
        rightImg = [[UIImageView alloc]initWithFrame:CGRectMake(SCREENWIDTH - 48, 0, 48, 33)];
        [rightImg setImage:[UIImage imageNamed:@"payment_list_wait_"]];
        rightImg.hidden = YES;
        [self.contentView addSubview:rightImg];
        
    }
    
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)creatCell:(SY_Par_PaymentModel *)model {
    
    NSString * picURL = [NSString stringWithFormat:@"%@%@",IMAGEHOSTURL,model.toppic];
    [leftImg sd_setImageWithURL:[NSURL URLWithString:picURL] placeholderImage:[UIImage imageNamed:@"noImage"]];
    
    titleLabel.text = model.name;
    contentLabel.text = model.scontent;
    
    if (model.state == 1) {
        [rightImg setImage:[UIImage imageNamed:@"payment_list_wait_"]];
        rightImg.hidden = NO;
    }else if (model.state == 3){
        [rightImg setImage:[UIImage imageNamed:@"payment_list_none_"]];
        rightImg.hidden = NO;
    }
    if (model.state == 3 || model.state == 4){
        stateLabel.text = @"已结束";
        stateLabel.textColor = colorFromHex(@"#dddddd");
    }
    if (model.state == 9) {
        stateLabel.text = @"未开始";
    }
    
    
}

@end
